﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.ObjectModel;

namespace Watson.TemporaryFilesDeleter
{
    /// <summary>
    /// Provides access to the standard and custom locations of temporary
    /// files.
    /// </summary>
    public class TemporaryFilesLocationsProvider
    {
        #region Static Private Fields

        /// <summary>
        /// A read-only collection of the standard locations of temporary
        /// files.
        /// </summary>
        static private readonly ReadOnlyCollection<string> standardLocations = 
            GetStandardLocations();

        #endregion


        #region Public Properties

        /// <summary>
        /// Gets a read-only collection of the standard locations of temporary
        /// files.
        /// </summary>
        public ICollection<string> StandardLocations
        {
            get { return standardLocations; }
        }

        #endregion


        #region Private Static Methods

        /// <summary>
        /// Obtains the standard locations of temporary files.
        /// </summary>
        /// <returns>
        /// System.Collections.ObjectModel.ReadOnlyCollection&gt;String&lt;
        /// <para>
        /// Read-only collection of standard locations of temporary files.
        /// </para>
        /// </returns>
        private static ReadOnlyCollection<string> GetStandardLocations()
        {
            // TODO: A better implementation for GetStandardLocations().
            //       Can we obtain, for example, the temporary locations for
            //       other users?

            string currentUserTempDir = System.IO.Path.GetTempPath();
            
            string localSystemTempDir = @"C:\WINDOWS\Temp\";

            Collection<string> tempDirs = new Collection<string>();

            tempDirs.Add(@"C:\ATemporaryTempFolder\");
            tempDirs.Add(currentUserTempDir);
            tempDirs.Add(localSystemTempDir);
            tempDirs.Add(@"C:\Program Files\Microsoft SDKs\");

            return new ReadOnlyCollection<string>(tempDirs);
        }
        
        #endregion
    }
}
